#include<stdio.h>
#include<errno.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

int main(int argc,char **argv)
{
    if(argc != 2)
        printf("usage:argv[0] <pathname>\n");

    else if(access(argv[1],R_OK) < 0)
        printf("access failure: %s\n",strerror(errno));
    else 
        printf("read access OK\n");
    if(open(argv[1],O_RDONLY) < 0)
        printf("open failure: %s\n",strerror(errno));
    else
        printf("open for reading ok\n");

    return 0;
}
